<!-- src/components/ProjectInfoCard.vue -->
<template>
  <el-card shadow="hover" class="section-card">
    <template #header>项目信息</template>
    <el-form :model="internalForm" label-width="120px">
      <el-form-item label="项目编号" prop="projectId">
        <el-input v-model="internalForm.projectId" clearable disabled />
      </el-form-item>
      <el-form-item label="任务编号" prop="taskId">
        <el-input v-model="internalForm.taskId" clearable disabled />
      </el-form-item>
      <el-form-item label="项目名称" prop="projectName">
        <el-input
          v-model="internalForm.projectName"
          placeholder="请输入项目名称"
          clearable
        />
      </el-form-item>
      <el-form-item label="任务名称" prop="taskName">
        <el-input
          v-model="internalForm.taskName"
          placeholder="请输入任务名称"
          clearable
        />
      </el-form-item>
    </el-form>
  </el-card>
</template>

<script setup lang="ts">
// **务必把 defineProps 赋值给 props 变量**
import { computed } from 'vue'

const props = defineProps<{
  modelValue: {
    projectId: string
    taskId: string
    projectName: string
    taskName: string
  }
  submitted: boolean
}>()

const emit = defineEmits<{
  (e: 'update:modelValue', payload: {
    projectId: string
    taskId: string
    projectName: string
    taskName: string
  }): void
}>()

// 内部计算属性，读写都会触发 update:modelValue
const internalForm = computed({
  get() {
    return props.modelValue
  },
  set(val) {
    emit('update:modelValue', { ...val })
  }
})
</script>

<style scoped>
.section-card {
  margin-bottom: 16px;
}
</style>
